package c.d.a.a.i;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.Path.Direction;
import android.graphics.drawable.Drawable;
import c.d.a.a.a.a;
import c.d.a.a.c.l;
import c.d.a.a.d.e;
import c.d.a.a.e.b;
import c.d.a.a.j.d;
import c.d.a.a.j.g;
import c.d.a.a.j.h;
import com.github.mikephil.charting.charts.RadarChart;
import com.github.mikephil.charting.data.RadarEntry;
import com.pgl.sys.ces.out.ISdkLite;
import java.util.Objects;

/* compiled from: RadarChartRenderer */
public class i extends f {
    public RadarChart h;
    public Paint i;
    public Paint j;
    public Path k = new Path();
    public Path l = new Path();

    public i(RadarChart radarChart, a aVar, h hVar) {
        super(aVar, hVar);
        this.h = radarChart;
        Paint paint = new Paint(1);
        this.d = paint;
        paint.setStyle(Style.STROKE);
        this.d.setStrokeWidth(2.0f);
        this.d.setColor(Color.rgb(ISdkLite.REGION_UNSET, 187, 115));
        paint = new Paint(1);
        this.i = paint;
        paint.setStyle(Style.STROKE);
        this.j = new Paint(1);
    }

    public void b(Canvas canvas) {
        l lVar = (l) this.h.getData();
        int i0 = ((c.d.a.a.f.b.i) lVar.g()).i0();
        for (c.d.a.a.f.b.i iVar : lVar.i) {
            if (iVar.isVisible()) {
                Objects.requireNonNull(this.b);
                Objects.requireNonNull(this.b);
                float sliceAngle = this.h.getSliceAngle();
                float factor = this.h.getFactor();
                d centerOffsets = this.h.getCenterOffsets();
                d b = d.b(0.0f, 0.0f);
                Path path = this.k;
                path.reset();
                Object obj = null;
                for (int i = 0; i < iVar.i0(); i++) {
                    this.c.setColor(iVar.A0(i));
                    g.f(centerOffsets, ((((RadarEntry) iVar.q0(i)).a - this.h.getYChartMin()) * factor) * 1.0f, this.h.getRotationAngle() + ((((float) i) * sliceAngle) * 1.0f), b);
                    if (!Float.isNaN(b.b)) {
                        if (obj == null) {
                            path.moveTo(b.b, b.c);
                            obj = 1;
                        } else {
                            path.lineTo(b.b, b.c);
                        }
                    }
                }
                if (iVar.i0() > i0) {
                    path.lineTo(centerOffsets.b, centerOffsets.c);
                }
                path.close();
                if (iVar.t0()) {
                    Drawable d0 = iVar.d0();
                    if (d0 != null) {
                        l(canvas, path, d0);
                    } else {
                        k(canvas, path, iVar.h(), iVar.l());
                    }
                }
                this.c.setStrokeWidth(iVar.B());
                this.c.setStyle(Style.STROKE);
                if (!iVar.t0() || iVar.l() < ISdkLite.REGION_UNSET) {
                    canvas.drawPath(path, this.c);
                }
                d.d.c(centerOffsets);
                d.d.c(b);
            }
        }
    }

    public void c(Canvas canvas) {
        int i;
        float sliceAngle = this.h.getSliceAngle();
        float factor = this.h.getFactor();
        float rotationAngle = this.h.getRotationAngle();
        d centerOffsets = this.h.getCenterOffsets();
        this.i.setStrokeWidth(this.h.getWebLineWidth());
        this.i.setColor(this.h.getWebColor());
        this.i.setAlpha(this.h.getWebAlpha());
        int skipWebLineCount = this.h.getSkipWebLineCount() + 1;
        int i0 = ((c.d.a.a.f.b.i) ((l) this.h.getData()).g()).i0();
        d b = d.b(0.0f, 0.0f);
        for (i = 0; i < i0; i += skipWebLineCount) {
            g.f(centerOffsets, this.h.getYRange() * factor, (((float) i) * sliceAngle) + rotationAngle, b);
            canvas.drawLine(centerOffsets.b, centerOffsets.c, b.b, b.c, this.i);
        }
        d.d.c(b);
        this.i.setStrokeWidth(this.h.getWebLineWidthInner());
        this.i.setColor(this.h.getWebColorInner());
        this.i.setAlpha(this.h.getWebAlpha());
        skipWebLineCount = this.h.getYAxis().m;
        d b2 = d.b(0.0f, 0.0f);
        d b3 = d.b(0.0f, 0.0f);
        for (int i2 = 0; i2 < skipWebLineCount; i2++) {
            i = 0;
            while (i < ((l) this.h.getData()).e()) {
                float yChartMin = (this.h.getYAxis().k[i2] - this.h.getYChartMin()) * factor;
                g.f(centerOffsets, yChartMin, (((float) i) * sliceAngle) + rotationAngle, b2);
                i++;
                g.f(centerOffsets, yChartMin, (((float) i) * sliceAngle) + rotationAngle, b3);
                canvas.drawLine(b2.b, b2.c, b3.b, b3.c, this.i);
            }
        }
        d.d.c(b2);
        d.d.c(b3);
    }

    public void d(Canvas canvas, b[] bVarArr) {
        Canvas canvas2 = canvas;
        b[] bVarArr2 = bVarArr;
        float sliceAngle = this.h.getSliceAngle();
        float factor = this.h.getFactor();
        d centerOffsets = this.h.getCenterOffsets();
        d b = d.b(0.0f, 0.0f);
        l lVar = (l) this.h.getData();
        int length = bVarArr2.length;
        int i = 0;
        while (i < length) {
            float f;
            float f2;
            b bVar = bVarArr2[i];
            c.d.a.a.f.b.i iVar = (c.d.a.a.f.b.i) lVar.c(bVar.f);
            if (iVar != null && iVar.n0()) {
                RadarEntry radarEntry = (RadarEntry) iVar.q0((int) bVar.a);
                if (h(radarEntry, iVar)) {
                    float yChartMin = (radarEntry.a - this.h.getYChartMin()) * factor;
                    Objects.requireNonNull(this.b);
                    yChartMin *= 1.0f;
                    float f3 = bVar.a * sliceAngle;
                    Objects.requireNonNull(this.b);
                    g.f(centerOffsets, yChartMin, this.h.getRotationAngle() + (f3 * 1.0f), b);
                    f3 = b.b;
                    float f4 = b.c;
                    bVar.i = f3;
                    bVar.j = f4;
                    j(canvas2, f3, f4, iVar);
                    if (!(!iVar.G() || Float.isNaN(b.b) || Float.isNaN(b.c))) {
                        int z = iVar.z();
                        if (z == 1122867) {
                            z = iVar.A0(0);
                        }
                        if (iVar.n() < ISdkLite.REGION_UNSET) {
                            int n = iVar.n();
                            int i2 = c.d.a.a.j.a.a;
                            z = (z & 16777215) | ((n & ISdkLite.REGION_UNSET) << 24);
                        }
                        yChartMin = iVar.k();
                        float S = iVar.S();
                        int i3 = iVar.i();
                        float d = iVar.d();
                        canvas.save();
                        S = g.d(S);
                        yChartMin = g.d(yChartMin);
                        if (i3 != 1122867) {
                            Path path = this.l;
                            path.reset();
                            f = sliceAngle;
                            f2 = factor;
                            path.addCircle(b.b, b.c, S, Direction.CW);
                            if (yChartMin > 0.0f) {
                                path.addCircle(b.b, b.c, yChartMin, Direction.CCW);
                            }
                            this.j.setColor(i3);
                            this.j.setStyle(Style.FILL);
                            canvas2.drawPath(path, this.j);
                        } else {
                            f = sliceAngle;
                            f2 = factor;
                        }
                        if (z != 1122867) {
                            this.j.setColor(z);
                            this.j.setStyle(Style.STROKE);
                            this.j.setStrokeWidth(g.d(d));
                            canvas2.drawCircle(b.b, b.c, S, this.j);
                        }
                        canvas.restore();
                        i++;
                        bVarArr2 = bVarArr;
                        sliceAngle = f;
                        factor = f2;
                    }
                }
            }
            f = sliceAngle;
            f2 = factor;
            i++;
            bVarArr2 = bVarArr;
            sliceAngle = f;
            factor = f2;
        }
        d.d.c(centerOffsets);
        d.d.c(b);
    }

    public void e(Canvas canvas) {
        Objects.requireNonNull(this.b);
        Objects.requireNonNull(this.b);
        float sliceAngle = this.h.getSliceAngle();
        float factor = this.h.getFactor();
        d centerOffsets = this.h.getCenterOffsets();
        d b = d.b(0.0f, 0.0f);
        d b2 = d.b(0.0f, 0.0f);
        float d = g.d(5.0f);
        int i = 0;
        while (i < ((l) this.h.getData()).d()) {
            float f;
            c.d.a.a.f.b.i iVar = (c.d.a.a.f.b.i) ((l) this.h.getData()).c(i);
            Canvas canvas2;
            if (i(iVar)) {
                a(iVar);
                e h0 = iVar.h0();
                d c = d.c(iVar.j0());
                c.b = g.d(c.b);
                c.c = g.d(c.c);
                int i2 = 0;
                while (i2 < iVar.i0()) {
                    RadarEntry radarEntry = (RadarEntry) iVar.q0(i2);
                    g.f(centerOffsets, ((radarEntry.a - this.h.getYChartMin()) * factor) * 1.0f, this.h.getRotationAngle() + ((((float) i2) * sliceAngle) * 1.0f), b);
                    if (iVar.V()) {
                        Objects.requireNonNull(h0);
                        String a = h0.a(radarEntry.a);
                        float f2 = b.b;
                        float f3 = b.c - d;
                        f = sliceAngle;
                        this.e.setColor(iVar.s(i2));
                        canvas.drawText(a, f2, f3, this.e);
                    } else {
                        canvas2 = canvas;
                        f = sliceAngle;
                    }
                    i2++;
                    sliceAngle = f;
                }
                canvas2 = canvas;
                f = sliceAngle;
                d.d.c(c);
            } else {
                canvas2 = canvas;
                f = sliceAngle;
            }
            i++;
            sliceAngle = f;
        }
        d.d.c(centerOffsets);
        d.d.c(b);
        d.d.c(b2);
    }

    public void f() {
    }
}
